package org.yookiee.support.core;

import com.google.common.base.Strings;

/**
 * FileName TimeZone
 * Package org.jeecg.config.i18n
 * Description  This enum supported by default.
 *              If you need to extend the supported languages and time zone types, please extend this enumeration
 *
 * author cpstory
 * create 2023-10-23 19:46
 * version V1.0
 */
public enum EasyTimeZone {

    /**美国时区*/
    AMERICA_LOS_ANGELES("America/Los_Angeles","UTC-8",-8,"${system_timezone.#AMERICA_LOS_ANGELES}"),//太平洋时间
    AMERICA_DENVER("America/Denver","UTC-7",-7,"${system_timezone.#AMERICA_DENVER}"),//山地时间
    AMERICA_CHICAGO("America/Chicago","UTC-6",-6,"${system_timezone.#AMERICA_CHICAGO}"),//中部时间
    AMERICA_NEW_YORK("America/New_York","UTC-5",-5,"${system_timezone.#AMERICA_NEW_YORK}"),//东部时间
    AMERICA_ANCHORAGE("America/Anchorage","UTC-9",-9,"${system_timezone.#AMERICA_ANCHORAGE}"),//阿拉斯加时间

    /**中国时区*/
    ASIA_SHANGHAI("Asia/Shanghai","UTC+8",8,"${system_timezone.#ASIA_SHANGHAI}"),//中国标准时间

    /**日本时区*/
    ASIA_TOKYO("Asia/Tokyo","UTC+9",9,"${system_timezone.#ASIA_TOKYO}"),//日本标准时间


    ;

    private String timezone;

    private String code;

    private Integer offset;

    private String desc;

    EasyTimeZone(String timezone, String code, Integer offset, String desc) {
        this.timezone = timezone;
        this.code = code;
        this.offset = offset;
        this.desc = desc;
    }

    public static EasyTimeZone formatByCode(String code){
        if(Strings.isNullOrEmpty(code)){
            return null;
        }

        for (EasyTimeZone value : EasyTimeZone.values()) {
            if(value.code.equals(code.trim())){
                return value;
            }
        }
        return null;
    }

    public static EasyTimeZone formatByTimeZone(String timezone){
        if(Strings.isNullOrEmpty(timezone)){
            return null;
        }

        for (EasyTimeZone value : EasyTimeZone.values()) {
            if(value.timezone.equals(timezone.trim())){
                return value;
            }
        }
        return null;
    }

    public String getTimezone() {
        return timezone;
    }

    public void setTimezone(String timezone) {
        this.timezone = timezone;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Integer getOffset() {
        return offset;
    }

    public void setOffset(Integer offset) {
        this.offset = offset;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
}
